import { createRouter, createWebHistory } from "vue-router";

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: "/",
      redirect: "/movie",
    },
    {
      path: "/movie",
      name: "movie",
      meta: { title: "电影", isTabPage: true },
      component: () => import("../views/MovieView.vue"),
      children: [
        {
          path: "/movie",
          redirect: "/movie/nowplaying",
        },
        {
          path: "nowplaying",
          name: "nowplaying",
          component: () => import("../components/nowplaying/NowPlaying.vue"),
        },
        {
          path: "coming",
          name: "coming",
          component: () => import("../components/comming/Coming.vue"),
        },
      ],
    },
    {
      path: "/cinema",
      name: "cinema",
      meta: { title: "影院", isTabPage: true },
      component: () => import("../views/CinemaView.vue"),
    },
    {
      path: "/news",
      name: "news",
      meta: { title: "资讯", isTabPage: true },

      component: () => import("../views/NewsView.vue"),
    },

    {
      path: "/user",
      name: "user",
      meta: { title: "个人中心", hideTitle: true },
      component: () => import("../views/UserView.vue"),
    },
    {
      path: "/soul",
      name: "soul",
      meta: { title: "仿soul", hideTitle: true },
      component: () => import("../views/SoulView.vue"),
    },
    {
      path: "/three",
      name: "three",
      meta: { title: "仿soul", hideTitle: true },
      component: () => import("../views/Three.vue"),
    },
    {
      path: "/moviedetails",//正则表达式，只匹配4位数的id
      name: "details",
      meta: { hideTabBar: true },
      component: () => import("../components/nowplaying/MovieDetails.vue"),
    },
    //城市列表页 
    {
      path: "/cities",
      name: "cities",
      meta: { title: "当前城市-", hideTabBar: true },
      component: () => import("../views/CitiesView.vue"),
    },
    // {
    //   path: "/movie/:id(\\d{4})",
    //   name: "detail",
    //   meta: { hideTabBar: true },
    //   component: Detail,
    // },
    //404页面 
     {
      path: "/:pm(.*)*",
      name: "notfound",
      component: () => import("../views/NotFound.vue"),
   },
  ],
});

export default router;
